<?php	
$db = new SQLite3('../db/ho4.db3');
$dir = $_GET['dir'];
$sort = $_GET['sort'];
$name1 = $_GET['city'];
$name2 = $_GET['struct'];
$name3 = $_GET['ded'];
$name4 = $_GET['cov'];
$name5 = $_GET['dist'];
$did = $db->query("select ho4.company, home.grpname, ho4.premium, home.cr08, home.cr07, home.cr06, home.cr05, home.cr04, home.short, home.phone, home.web, home.ambest, home.ms08 from ho4, home where ho4.city='$name1' AND ho4.structure='$name2' AND ho4.deductible='$name3' AND ho4.coverage='$name4' AND ho4.distance='$name5' AND ho4.company=home.company ORDER BY $sort $dir");
while($obj = $did->fetchArray(SQLITE3_ASSOC))
{
	$arr[] = $obj;
}
echo '{"results":'.json_encode($arr).'}';
?>